package com.hnust.controller.paper.paperManagement;
import com.hnust.controller.MainController;
import com.hnust.domain.*;
import com.hnust.fx.FXMLController;
import com.hnust.service.*;
import com.hnust.store.DataStore;
import com.hnust.store.PaperListDataStore;
import com.hnust.domain.JudgeAnswerPartDto;
import com.hnust.util.PaperDataModel;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.geometry.Pos;
import javafx.scene.control.*;
import javafx.scene.image.*;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import org.springframework.beans.factory.annotation.Autowired;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

import java.net.URL;
import java.util.*;

@FXMLController
public class PaperReviewController implements Initializable {

    public static PaperDataModel model = new PaperDataModel();
    public static String paperId,testId,teacherId,testname; //从PaperList传来的试卷ID，考试ID

    @FXML
    public HBox topNav;//顶部导航栏
    @FXML
    public Label testName;//考试名
    @FXML
    public ComboBox classCombobox;//班级下拉框
    @FXML
    public HBox bottomMain;//下部主体部分
    @FXML
    public VBox leftChildren;//下部左半部分
    @FXML
    public VBox rightChildren;//下部又半部分
    @FXML
    public VBox paperText;//试卷批阅
    @FXML
    public ScrollPane paper;//试卷题目详细
    @FXML
    public ProgressBar testProgress;//进度条

    @FXML
    public VBox paperCard;//答题卡
    @FXML
    public VBox cardPanel;//答题卡面板
//    @FXML
//    public Label change;


    @FXML
    public VBox studentMsg;//学生信息
    @FXML
    public Label num;
    @FXML
    public ImageView avatar;
    @FXML
    public Label n;
    @FXML
    public Label i;
    @FXML
    public Label s;
    @FXML
    public ImageView imgScore;
    @FXML
    public ImageView imgTime;
    @FXML
    public Label sc;
    @FXML
    public Label t;

    @FXML
    public VBox studentNum;//学生人数
    @FXML
    public GridPane avatars;
    @FXML
    public Button prv;
    @FXML
    public Button next;
    @FXML
    public Button finishStuButton;
    @FXML
    public Button finish;

    @Autowired
    private DataStore dataStore;
    @Autowired
    private PaperListDataStore paperListDataStore;
    @Autowired
    private PaperManageServices paperManageServices;
    @Autowired
    private StuListService stuListService;
    @Autowired
    private GetStuObjectiveQueMsgServices getStuObjectiveQueMsgServices;
    @Autowired
    private ClassService classService;
    @Autowired
    private TestPaperService testPaperService; //对应的service层

    @FXML
    public Button generatePaper;
    @FXML
    public Button autoPaper;
    @FXML
    public ScrollPane container;
    @FXML
    public VBox contain;

    @FXML
    public VBox mainShowBox;
    @FXML
    public VBox mainCardBox;

    @FXML
    public HBox eachSubQueTopHBox;
    @FXML
    public TextField scoreTextField;
    @FXML
    public Button  confirmScoreButton;
    @FXML
    public Button addContentButton;
    @FXML
    public Label questionNumLabel;
    @FXML
    public Label questionTypeLabel;
    @FXML
    public HBox questionContentBigHBox;
    @FXML
    public Label questionContentLabel;
    @FXML
    public HBox scoreHBox;
    @FXML
    public HBox scoreLongHBox;
    @FXML
    public HBox scoreTextHBox;
    @FXML
    public Label questionScoreLabel;
    @FXML
    public HBox studentAnswerHBox;
    @FXML
    public HBox studentAnswerContentHBox;
    @FXML
    public HBox RightAnswerHBox;
    @FXML
    public HBox RightAnswerContentHBox;
    @FXML
    public Label analyze;
    @FXML
    public HBox jumpBigHBox;
    @FXML
    public HBox jumpLongHBox;
    @FXML
    public HBox jumpButtonHBox;
    @FXML
    public Button preQueButton;
    @FXML
    public Button nextQueButton;
    @FXML
    public VBox gotoSubjectiveVbox;
    @FXML
    public VBox gotoObjectiveVbox;
    @FXML
    public Label toSubLabel;
    @FXML
    public Label toObjLabel;
    @FXML
    public VBox questionContentVBox;
    @FXML
    public VBox ObjectiveQuetions;
    @FXML
    public TextArea questionContentTextArea;
    @FXML
    public VBox eachQueDetailBox;
    @FXML
    public VBox optionVbox;

    @FXML
    public HBox questionContentPicHbox;


    @Autowired
    private MainController mainController;
    @Autowired
    private PaperListController paperListController;

    //用于计数当前是第几号学生
    private int index=0;
    //班级学生列表
    private List<Examinee> ClassStudent;
    //学生总人数
    private Integer AllClassNum;
    //学生客观题答案
    private StudentAnswerPartDto studentAnswerPartDto;
    //客观题正确答案
    private PaperAnswerPartDto paperAnswerPartDto;
    //学生客观题正误情况
    private JudgeAnswerPartDto judgeAnswerPartDto;
    //也是班级学生列表
    private List<Examinee> stuList;
    //正在批阅的题目序号
    private Integer nowQuetionNum;     //从1开始
    //进度条百分比
    private Double ProgressMsg;
    //正在批阅的学生id
    private String nowStuId ;
    //正在批阅的学生序号
    private Integer nowStuNum = 0;
    //正在批阅的题目id
    private String nowQuestionId;
    //正在批阅的班级序号
    private int nowClassNum = 0;
    //当前正在显示在屏幕的某学生考试情况的3个id
////    private String testId = "976475";
//    private String testId = "10010";
////    private String paperId= "9195396997";
//    private String paperId= "1";
//    private String studentId = "2006040306";
//    private String studentId;
    //图片头像地址
    private String[] images = {
            "image/main/PaperReview/man.png",//男生头像
            "image/main/PaperReview/woman.png"//女生头像
    };
    //是否从主观题界面跳到客观题界面的标志（1表示跳，0表示不跳）
    private int flag = 1;

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        //屏幕自适应
        listenChange();
        //布局自适应
        DetermineLayout();
        //数据加载
        AddData();
        //事件监听
        ListenEvents();
    }
    //可以用于消除滚动条
    public void listenChange() {
        //通过监听最外层容器的宽度，来改变内层VBox的宽度
        container.widthProperty().addListener(new ChangeListener<Number>() {
            @Override
            public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                contain.setPrefWidth((double)newValue-2);
            }
        });
        //通过监听最外层容器的高度，来改变内层VBox的高度
        container.heightProperty().addListener(new ChangeListener<Number>() {
            @Override
            public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                contain.setPrefHeight((double)newValue-2);
            }
        });
    }
    //确定内部布局
    public void DetermineLayout() {
        //导航栏布局
        topNav.prefWidthProperty().bind(contain.widthProperty());
        topNav.prefHeightProperty().bind(contain.heightProperty().multiply(0.05));
        testName.prefWidthProperty().bind(topNav.widthProperty().multiply(0.68));
        classCombobox.prefWidthProperty().bind(topNav.widthProperty().multiply(0.15));

        //主体布局
        bottomMain.prefWidthProperty().bind(contain.widthProperty());
        bottomMain.prefHeightProperty().bind(contain.heightProperty().multiply(0.94));

        //主体左边部分占比
        leftChildren.prefWidthProperty().bind(bottomMain.widthProperty().multiply(0.78));
        leftChildren.prefHeightProperty().bind(bottomMain.heightProperty());

        //主体右边部分占比
        rightChildren.prefWidthProperty().bind(bottomMain.widthProperty().multiply(0.22));
        rightChildren.prefHeightProperty().bind(bottomMain.heightProperty());

        //左边分块
        paperText.prefWidthProperty().bind(leftChildren.widthProperty());
        paperText.prefHeightProperty().bind(leftChildren.heightProperty().multiply(0.55));
        testProgress.prefWidthProperty().bind(leftChildren.widthProperty());
        paper.prefWidthProperty().bind(paperText.widthProperty());
        paper.prefHeightProperty().bind(paperText.heightProperty());

        paperCard.prefWidthProperty().bind(leftChildren.widthProperty());
        paperCard.prefHeightProperty().bind(leftChildren.heightProperty().multiply(0.44));

        //右边分块
        studentMsg.prefWidthProperty().bind(rightChildren.widthProperty());
        studentMsg.prefHeightProperty().bind(rightChildren.heightProperty().multiply(0.42));

        studentNum.prefWidthProperty().bind(rightChildren.widthProperty());
        studentNum.prefHeightProperty().bind(rightChildren.heightProperty().multiply(0.58));
    }
    //加载各项数据
    public void AddData() {
        String[] text=model.getText().split(" ");
        //下面是接受试卷列表跳转本页面所带来的相应数据参数
        paperId=text[0];
        System.out.println("paperId"+paperId);
        testId=text[1];
        System.out.println("testId"+testId);
        teacherId=text[2];
        System.out.println("teacherId="+teacherId);
        testname=text[3];
        System.out.println("testname="+testname);
        model.textProperty().addListener((obs, oldText, newText) -> {
            paperId=newText;
        });
        System.out.println("initialize :");
        //获取text_id
        paperListDataStore.setTest_id("123");//整合时删除
        ProgressMsg = 0.0;
        ChangeProgress(ProgressMsg);//修改进度条的进度
//        AddClassData(testId,0);
        SubjToOb();         //初始隐藏一下界面
        ChangeTestName();//修改考试名
        AddComboboxData();//添加下拉框的数据并加载所有数据

//        //调用接口获取所有信息保存在公共变量中
//        paperAnswerPartDto  = getStuObjectiveQueMsgServices.getPaperAnswerPartDto(paperId).getData();
//        System.out.println("这是从后端获取的数据1");
//        System.out.println("这是学生id"+nowStuId);
//        System.out.println(paperAnswerPartDto);
//        studentAnswerPartDto = getStuObjectiveQueMsgServices.getStudentAnswerPartDto(testId, paperId, nowStuId).getData();
//        System.out.println("这是从后端获取的数据2");
//        System.out.println(studentAnswerPartDto);
//        judgeAnswerPartDto = getStuObjectiveQueMsgServices.getJudgeAnswerPartDto(testId, paperId, nowStuId).getData();
//        System.out.println("这是从后端获取的数据3");
//        System.out.println(judgeAnswerPartDto);
//        GetObjectiveQuestion(testId,paperId,nowStuId,0);
    }
    public static void setText(String text) {
        model.setText(text);
    }
    //各种事件设置
    public void ListenEvents(){
        //点击完成批阅按钮事件（完成该生批阅按钮）
        finishStuButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
                alert.setTitle("确认信息");
                alert.setHeaderText("确认该学生批阅情况");
                alert.setContentText("你确定完成该学生的批阅吗？");
                Optional<ButtonType> result = alert.showAndWait();
                if (result.get() == ButtonType.OK){
                    getStuObjectiveQueMsgServices.changeStuTestStatus(new Callback<Result<Boolean>>() {
                        @Override
                        public void onResponse(Call<Result<Boolean>> call, Response<Result<Boolean>> response) {
                            Platform.runLater(new Runnable() {
                                @Override
                                public void run() {
                                    assert response.body() != null;
                                    if (response.body().getData()) {
                                        AddClassData(testId,nowClassNum);
                                        Alert alert = new Alert(Alert.AlertType.INFORMATION);
                                        alert.setTitle("提示信息");
                                        alert.setHeaderText(null);
                                        alert.setContentText("成功批阅该学生成绩");
                                        alert.showAndWait();
                                    }
                                    else{
                                        Alert alert = new Alert(Alert.AlertType.ERROR, "提交失败！请重新提交");
                                        alert.showAndWait();
                                    }
                                }
                            });
                        }
                        @Override
                        public void onFailure(Call<Result<Boolean>> call, Throwable throwable) {

                        }
                    },testId,nowStuId);
                }
            }
        });

        //点击结束批阅按钮事件
        finish.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
                alert.setTitle("确认信息");
                alert.setHeaderText("确认该考试批阅情况");
                alert.setContentText("你确定完成该考试所有班级的批阅吗？");
                Optional<ButtonType> result = alert.showAndWait();
                if (result.get() == ButtonType.OK){
                    getStuObjectiveQueMsgServices.changeTeacherTestStatus(new Callback<Result<Boolean>>() {
                        @Override
                        public void onResponse(Call<Result<Boolean>> call, Response<Result<Boolean>> response) {
                            Platform.runLater(new Runnable() {
                                @Override
                                public void run() {
                                    assert response.body() != null;
                                    if (response.body().getData()) {    //结束批阅之后跳往试卷列表界面
                                        mainController.skipView("试卷列表");
                                        paperListController.jumpFromPaperReview();
                                    }
                                    else{
                                        Alert alert = new Alert(Alert.AlertType.ERROR, "提交失败！请重新提交");
                                        alert.showAndWait();
                                    }
                                }
                            });
                        }
                        @Override
                        public void onFailure(Call<Result<Boolean>> call, Throwable throwable) {

                        }
                    },testId,teacherId);
                }

            }
        });

        //点击确认分值按钮事件
        confirmScoreButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                String newScore = scoreTextField.getText();
                System.out.println("确认分值时的nowStuId是--------"+nowStuId);
                System.out.println("确认分值时的nowQuetionNum是--------"+nowQuetionNum);
                ChangeRequest changeRequest = new ChangeRequest(testId,nowStuId,nowQuetionNum+"",Integer.parseInt(newScore));
                getStuObjectiveQueMsgServices.changeScore(new Callback<Result<Boolean>>() {
                    @Override
                    public void onResponse(Call<Result<Boolean>> call, Response<Result<Boolean>> response) {
                        Platform.runLater(new Runnable() {
                            @Override
                            public void run() {
                                assert response.body() != null;
                                if (response.body().getData()) {
                                    flag = 0;   //从这里重新加载学生答题信息，做标记表示这种情况不需要 GetObjectiveQuestion方法里的跳转客观题的方法
                                    System.out.println("现在的学生序号--"+nowStuNum);
                                    AddClassData(testId,nowClassNum);
                                }
                                else{
                                    Alert alert = new Alert(Alert.AlertType.ERROR, "修改失败！");
                                    alert.showAndWait();
                                }
                            }
                        });
                    }
                    @Override
                    public void onFailure(Call<Result<Boolean>> call, Throwable throwable) {

                    }
                },changeRequest);

            }
        });
        //添加批注事件
        addContentButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                TextInputDialog dialog = new TextInputDialog("请输入批注");
                dialog.setTitle("批注输入框");
                dialog.setHeaderText("请在下方输入批注");
                dialog.setContentText("批注：");
                dialog.setWidth(300.0);
                dialog.setHeight(300.0);
                Optional<String> result = dialog.showAndWait();
                if (result.isPresent()) {
                    System.out.println("hhhhh"+result.get());
                    String msg = getStuObjectiveQueMsgServices.addAnnotation(nowStuId,testId,nowQuestionId,result.get()).getMsg();
                    if (msg.equals("添加批注成功")) {
                        Alert alert = new Alert(Alert.AlertType.INFORMATION, "添加批注成功");
                        alert.showAndWait();
                    } else {
                        Alert alert = new Alert(Alert.AlertType.ERROR, "添加批注失败");
                        alert.showAndWait();
                    }
                } else {
                    System.out.println("取消输入了");
                }
            }
        });

        //点击上一题事件
        preQueButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                preQuestionChange();
            }
        });
        //点击下一题事件
        nextQueButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                nextQuestionChange();
            }
        });
        //设置点击“点击进入主观题（客观题）事件”
        gotoObjectiveVbox.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                SubjToOb();
            }
        });
        gotoSubjectiveVbox.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                ObjToSub(null,null,1+"");
            }
        });
        //设置按钮prv的点击事件
        prv.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                ChangePrvAvatars();
            }
        });
        //设置按钮next的点击事件
        next.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                ChangeNextAvatars();
            }
        });

        classCombobox.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
            @Override
            public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                nowStuNum = 0;
                nowClassNum = (int) newValue;
                AddClassData(testId,(Integer) newValue);
            }
        });
    }
    //preQueButton的点击事件
    public void preQuestionChange(){
        String questionId = "";
        String questiontype = "";
        int choiceNum = paperAnswerPartDto.getQuestionSize().getSelectSize();
        int judgeNum = paperAnswerPartDto.getQuestionSize().getJudgeSize();
        int fillNum = paperAnswerPartDto.getQuestionSize().getFillSize();
        int shortNum = paperAnswerPartDto.getQuestionSize().getWriteSize();
        int newNum = nowQuetionNum-1;
        if(newNum<=0) {
            Alert alert = new Alert(Alert.AlertType.ERROR, "目前是第一题！");
            alert.showAndWait();
        }else {
            if((newNum>=1)&&(newNum<=choiceNum)) {
                System.out.println("选择题序号"+newNum);
                questionId = paperAnswerPartDto.getQuestionIdLists().getSelectIdList().get(newNum-1);
                questiontype = "选择题";

            }
            else if((newNum>shortNum)&&newNum<=choiceNum+judgeNum) {
                System.out.println("判断题序号为"+(newNum-choiceNum));
                questionId = paperAnswerPartDto.getQuestionIdLists().getJudgeIdList().get(newNum-choiceNum-1);
                questiontype = "判断题";
            }
            else if((newNum>shortNum+judgeNum)&&(newNum<=choiceNum+fillNum+judgeNum)) {
                System.out.println("填空题序号为"+(newNum-choiceNum-judgeNum));
                questionId = paperAnswerPartDto.getQuestionIdLists().getFillIdList().get(newNum-choiceNum-judgeNum-1);
                questiontype = "填空题";
            }
            else {
                System.out.println("简答题序号为"+(newNum-choiceNum-judgeNum-fillNum));
                questionId = paperAnswerPartDto.getQuestionIdLists().getWriteIdList().get(newNum-choiceNum-judgeNum-fillNum-1);
                questiontype = "简答题";
            }
            showQueDetailMsg(testId,questionId,nowStuId,questiontype,newNum+"");
            nowQuetionNum = newNum;
        }
    }
    //nextQueButton的点击事件
    public void nextQuestionChange(){
        String questionId = "";
        String questiontype = "";
        System.out.println("oldNum"+"---"+nowQuetionNum);
        int choiceNum = paperAnswerPartDto.getQuestionSize().getSelectSize();
        int judgeNum = paperAnswerPartDto.getQuestionSize().getJudgeSize();
        int fillNum = paperAnswerPartDto.getQuestionSize().getFillSize();
        int shortNum = paperAnswerPartDto.getQuestionSize().getWriteSize();
        int newNum = nowQuetionNum+1;
        System.out.println("newNum"+"---"+nowQuetionNum);
        if(newNum>choiceNum+judgeNum+fillNum+shortNum) {
            Alert alert = new Alert(Alert.AlertType.ERROR, "已是最后一题！");
            alert.showAndWait();
        }else {
            if((newNum>=1)&&(newNum<=choiceNum)) {
                System.out.println("选择题序号"+newNum);
                questionId = paperAnswerPartDto.getQuestionIdLists().getSelectIdList().get(newNum-1);
                questiontype = "选择题";

            }
            else if((newNum>shortNum)&&newNum<=choiceNum+judgeNum) {
                System.out.println("判断题序号为"+(newNum-choiceNum));
                questionId = paperAnswerPartDto.getQuestionIdLists().getJudgeIdList().get(newNum-choiceNum-1);
                questiontype = "判断题";
            }
            else if((newNum>shortNum+judgeNum)&&(newNum<=choiceNum+fillNum+judgeNum)) {
                System.out.println("填空题序号为"+(newNum-choiceNum-judgeNum));
                questionId = paperAnswerPartDto.getQuestionIdLists().getFillIdList().get(newNum-choiceNum-judgeNum-1);
                questiontype = "填空题";
            }
            else {
                System.out.println("简答题序号为"+(newNum-choiceNum-judgeNum-fillNum));
                questionId = paperAnswerPartDto.getQuestionIdLists().getWriteIdList().get(newNum-choiceNum-judgeNum-fillNum-1);
                questiontype = "简答题";
            }
            showQueDetailMsg(testId,questionId,nowStuId,questiontype,newNum+"");
            nowQuetionNum = newNum;
        }

    }
    public void ClearPreData(Pane pane) {
        pane.getChildren().clear();
    }

    //点击“点击进入主观题”和点击题目选项按钮时触发事件
    public void ObjToSub(String questionId,String questionType,String number){
        int allQuesize = paperAnswerPartDto.getQuestionSize().getWriteSize()+paperAnswerPartDto.getQuestionSize().getFillSize()+paperAnswerPartDto.getQuestionSize().getSelectSize()+paperAnswerPartDto.getQuestionSize().getJudgeSize();
        System.out.println("all"+allQuesize);
        System.out.println("number"+number);
        //隐藏客观题情况，渲染具体题目信息
        gotoSubjectiveVbox.setVisible(false);
        gotoSubjectiveVbox.setManaged(false);
        ObjectiveQuetions.setVisible(false);
        ObjectiveQuetions.setManaged(false);

        gotoObjectiveVbox.setVisible(true);
        gotoObjectiveVbox.setManaged(true);
        eachQueDetailBox.setVisible(true);
        eachQueDetailBox.setManaged(true);
        if (questionId==null) {
            nowQuestionId = paperAnswerPartDto.getQuestionIdLists().getWriteIdList().get(0);
            ProgressMsg = 1.0/allQuesize;
            showQueDetailMsg(testId,paperAnswerPartDto.getQuestionIdLists().getWriteIdList().get(0),nowStuId,"简答题",(allQuesize-paperAnswerPartDto.getQuestionSize().getWriteSize()+1)+"");
        }else {
            ProgressMsg = (1.0*Integer.parseInt(number))/allQuesize;
            showQueDetailMsg(testId,questionId,nowStuId,questionType,number);
        }
    }
    //点击“点击进入客观题”时触发事件
    public void SubjToOb(){
        //与ObjToSub()相反
        ProgressMsg = 0.0;
        gotoObjectiveVbox.setVisible(false);
        gotoObjectiveVbox.setManaged(false);
        eachQueDetailBox.setVisible(false);
        eachQueDetailBox.setManaged(false);
        gotoSubjectiveVbox.setVisible(true);
        gotoSubjectiveVbox.setManaged(true);
        ObjectiveQuetions.setVisible(true);
        ObjectiveQuetions.setVisible(true);
    }
    //设置考试名称
    public void ChangeTestName(){
        testName.setText(testname);
    }
    //设置班级信息
    public void AddComboboxData() {
        Result<List<String>> classes = classService.getClasses(teacherId,testId);
        List<String> classlist = classes.getData();
        System.out.println("设置班级信息-查询出班级列表"+classlist);
        ObservableList<String> obList = FXCollections.observableArrayList(classlist);
        classCombobox.setItems(obList);
//        classCombobox.setValue(0);
        classCombobox.getSelectionModel().select(0);
        AddClassData(testId,0);

    }
    public void changeAvatarColorByStuNum(int StuNum,int flag) {   //将stuNum序号的学生头像颜色进行变化,如果flag为0，则根据批改状态变色，如果为1就是亮色
        ImageView imageView = new ImageView();
        Image img;
        if(ClassStudent.get(StuNum).getSex().equals("男"))
           img = new Image(images[0]);
        else
            img = new Image(images[1]);
        if(flag==0&&ClassStudent.get(StuNum).getStatus().equals("0"))    //如果该学生批改状态是0表示未批阅就将其颜色变为暗色
            img = getGrayByColor(img);
        imageView.setImage(img);
        //点击学生头像，左边题目区域发生变化的事件
        imageView.setOnMouseClicked(event -> {
            System.out.println("点击了学生头像，该学生id如下");
            nowStuId = ClassStudent.get(StuNum).getStuId();
            System.out.println(nowStuId);
            changeAvatarColorByStuNum(nowStuNum,0);
            GetObjectiveQuestion(testId,paperId,ClassStudent.get(StuNum).getStuId(),StuNum);
            changeAvatarColorByStuNum(nowStuNum,1);
            System.out.println("现在的学生序号--"+nowStuNum);
            ShowStudentMsg(ClassStudent.get(StuNum),ClassStudent.size()+"");
        });
        VBox vBox = new VBox();
        vBox.getChildren().add(imageView);
        avatars.add(vBox,StuNum%4,StuNum/4);
    }
    //prv的点击事件
    public void ChangePrvAvatars(){
        System.out.println("旧的学生序号");
        System.out.println(nowStuNum);
        if (nowStuNum<=0) {
            Alert alert = new Alert(Alert.AlertType.ERROR, "目前是该班级第一个人！");
            alert.showAndWait();
        } else {
            changeAvatarColorByStuNum(nowStuNum,0);
            nowStuNum--;
            changeAvatarColorByStuNum(nowStuNum,1);
            ShowStudentMsg(ClassStudent.get(nowStuNum),AllClassNum.toString());
            System.out.println("这是学生列表hhh");
            System.out.println(ClassStudent);
            System.out.println("新的学生pre序号");
            System.out.println(nowStuNum);
            nowStuId = ClassStudent.get(nowStuNum).getStuId();
            System.out.println("改变后的学生id------"+ nowStuId);
            GetObjectiveQuestion(testId,paperId,ClassStudent.get(nowStuNum).getStuId(),nowStuNum);
        }
    }
    //next的点击事件
    public void ChangeNextAvatars(){
        System.out.println("旧的学生序号");
        System.out.println(nowStuNum);
        if(nowStuNum>=ClassStudent.size()-1) {
            Alert alert = new Alert(Alert.AlertType.ERROR, "已经是该班级最后一人！");
            alert.showAndWait();
        } else  {
            changeAvatarColorByStuNum(nowStuNum,0);
            nowStuNum++;
            changeAvatarColorByStuNum(nowStuNum,1);
            ShowStudentMsg(ClassStudent.get(nowStuNum),AllClassNum.toString());
            System.out.println("这是学生列表hhh");
            System.out.println(ClassStudent);
            System.out.println("新的学生pre序号");
            System.out.println(nowStuNum);
            nowStuId = ClassStudent.get(nowStuNum).getStuId();
            System.out.println("改变后的学生id------"+ nowStuId);
            GetObjectiveQuestion(testId,paperId,ClassStudent.get(nowStuNum).getStuId(),nowStuNum);
        }
    }

    public void AddClassData(String testId,int classNum) {
        ClassStudent = new ArrayList<>();
//        String classValue = classCombobox.getValue().toString();
        String classValue = classCombobox.getItems().get(classNum).toString();
//        String classValue = classCombobox.getItems().get(1).toString();
        System.out.println("加载-下拉框当前班级名"+classValue);
        //获取对应班级id
        String claid = classService.getClassId(classValue);
        System.out.println("加载-下拉框当前班级id"+claid);
        Result<Map<String, List<Examinee>>> msg = stuListService.getStuList(testId,claid);
        System.out.println("加载-下拉框当前班级"+msg.getData().get("student"));
        //打印出班级名称
        System.out.println("msg.getData().get(student)");
        System.out.println(msg.getData().get("student"));
        if(msg.getData().get("student").size()!=0) {
            nowStuId = msg.getData().get("student").get(nowStuNum).getStuId();
            System.out.println("目前的学生id"+nowStuId);
            //获得对应班级的学生
            ClassStudent = msg.getData().get("student");
            stuList = ClassStudent;
            AllClassNum = ClassStudent.size();
            ShowStudentMsg(ClassStudent.get(nowStuNum), AllClassNum.toString());//学生信息显示
            ShowClassMsg();//班级人数显示
            GetObjectiveQuestion(testId,paperId, nowStuId ,nowStuNum);   //显示该班级学生的考试情况信息
        }else {
            System.out.println("没找到");
        }
    }
    //展示下方班级所有学生的信息
    public void ShowClassMsg(){
        //      清空原来的内容
        ClearPreData(avatars);
        int size = ClassStudent.size();
        int i;
        for(i=0;i<size;i++){
            ImageView imageView = new ImageView();
            Label label1 = new Label();
            Label label2 = new Label();
            Image img;
            if(ClassStudent.get(i).getSex().equals("男")) {
                img = new Image(images[0]);
            }
            else{
                img = new Image(images[1]);
            }
            if(ClassStudent.get(i).getStatus().equals("0"))    //如果该学生批改状态是0表示未批阅就将其颜色变为暗色
                img = getGrayByColor(img);
            imageView.setImage(img);
            imageView.setFitHeight(64);
            imageView.setFitWidth(64);
            int finalI = i;
            imageView.setOnMouseClicked(new EventHandler<MouseEvent>() {     //点击学生头像，左边题目区域发生变化的事件
                @Override
                public void handle(MouseEvent event) {
                    System.out.println("点击了学生头像，该学生id变为如下");
                    nowStuId = ClassStudent.get(finalI).getStuId();
                    System.out.println(nowStuId);
                    changeAvatarColorByStuNum(nowStuNum,0);
                    GetObjectiveQuestion(testId,paperId,ClassStudent.get(finalI).getStuId(),finalI);
                    changeAvatarColorByStuNum(nowStuNum,1);
                    System.out.println("现在的学生序号--"+nowStuNum);
                    ShowStudentMsg(ClassStudent.get(finalI),ClassStudent.size()+"");
                }
            });
            label1.setText("姓名:"+stuList.get(i).getStuName());    //后端拿取的学生名字+学生分数，中间用空格拼接
            label2.setText("成绩"+stuList.get(i).getScore());
            VBox vBox = new VBox();
            vBox.getChildren().add(imageView);
            vBox.getChildren().add(label1);
            vBox.getChildren().add(label2);
            avatars.add(vBox,(i%4),(i/4));
        }
        //上面的代码是首先让所有人的头像颜色根据批改状态变色，下面的代码是让目前正在修改的学生头像变为亮色
        changeAvatarColorByStuNum(nowStuNum,1);
    }
    //设置进度条进度
    public void ChangeProgress(double Progress) {
        testProgress.setProgress(Progress);
    }
    //渲染学生信息
    public void ShowStudentMsg(Examinee student,String ClassNum) {
        String studentid = student.getStuNumber();
        String Newnum = nowStuNum+1+"";
        //设置 当前学生序号/总的学生数
        setStudentNum(Newnum,ClassNum);
        //设置 男女两种头像 和 设置 学生信息
        setAvatarAndMsg(student.getSex(),student.getStuName(),studentid);
        //设置考试分数和作答时间
        setScoreAndTime(student.getScore(),student.getTime());
    }
    //设置 当前学生序号/总的学生数
    public void setStudentNum(String Newnum,String Allnum) {
        num.setText(Newnum+'/'+Allnum);
    }
    //设置 男女两种头像 和 设置 学生信息
    public void setAvatarAndMsg(String sex,String name,String id) {
        if(sex.equals("男"))
            avatar.setImage(new Image(images[0]));
        else
            avatar.setImage(new Image(images[1]));
        avatar.setFitHeight(100);
        avatar.setFitWidth(100);
        n.setText("考生姓名："+name);
        i.setText("学号："+id);
        s.setText("班级："+classCombobox.getValue().toString());
    }

    //设置考试分数和作答时间
    public void setScoreAndTime(String score,String time) {
        String[] images = {
                "image/main/PaperReview/score.png",//考试分数
                "image/main/PaperReview/time.png"//考试时间
        };
        imgScore.setImage(new Image(images[0]));
        imgTime.setImage(new Image(images[1]));
        sc.setText("分数："+score+"分");
        t.setText("答题时长："+time);
    }
    //获取灰度图
    public Image getGrayByColor(Image image) {
        int width = (int) image.getWidth();
        int height = (int) image.getHeight();
        WritableImage grayImage = new WritableImage(width,height);
        PixelReader pixelReader = image.getPixelReader();
        PixelWriter pixelWriterGray = grayImage.getPixelWriter();
        for(int i=0;i<width;i++) {
            for(int j=0;j<height;j++) {
                Color color = pixelReader.getColor(i, j);
                color = color.grayscale();
                pixelWriterGray.setColor(i,j,color);
            }
        }
        return grayImage;
    }
    //显示指定题目详细内容的方法
    public void showQueDetailMsg(String testId, String questionId,String studentId,String questionType,String number){
        System.out.println("信息如下");
        System.out.println(testId);
        System.out.println(questionId);
        System.out.println(studentId);
        System.out.println(questionType);
        System.out.println(number);
        questionContentPicHbox.getChildren().clear();
        optionVbox.getChildren().clear();
        nowQuetionNum = Integer.parseInt(number);
        //调用接口获取题目信息
        QuestionAnswer questionAnswer = getStuObjectiveQueMsgServices.getQueDetailMsg(testId, questionId, studentId, questionType, number).getData();
        System.out.println("具体题目信息如下");
        System.out.println(questionAnswer);
//       确认分值和添加批注区域
        ArrayList<Integer> listScore = new ArrayList<>();
        if (judgeAnswerPartDto.getQuestionScore().getSelectScoreList()!=null){
            listScore.addAll(judgeAnswerPartDto.getQuestionScore().getSelectScoreList());
        }
        if (judgeAnswerPartDto.getQuestionScore().getJudgeScoreList()!=null){
            listScore.addAll(judgeAnswerPartDto.getQuestionScore().getJudgeScoreList());
        }
        if (judgeAnswerPartDto.getQuestionScore().getFillScoreList()!=null){
            listScore.addAll(judgeAnswerPartDto.getQuestionScore().getFillScoreList());
        }
        if (judgeAnswerPartDto.getQuestionScore().getWriteScoreList()!=null){
            listScore.addAll(judgeAnswerPartDto.getQuestionScore().getWriteScoreList());
        }
        String nowScore = listScore.get(Integer.parseInt(number)-1)+"";
        System.out.println("num"+number);
        System.out.println("score"+nowScore);
        scoreTextField.setText(nowScore);

//        题目序号和题型区域
        questionNumLabel.setText(number+"、");
        questionTypeLabel.setText(questionType);
        switch (questionType) {
            case "选择题":
                questionTypeLabel.setStyle("-fx-text-fill: #3498db; -fx-border-color:#3498db;-fx-border-width: 1px; -fx-padding: 1px;");
                break;
            case "填空题":
                questionTypeLabel.setStyle("-fx-text-fill: #2ecc71; -fx-border-color:#2ecc71;-fx-border-width: 1px; -fx-padding: 1px;");
                break;
            case "判断题":
                questionTypeLabel.setStyle("-fx-text-fill: #f04e0e; -fx-border-color:#f04e0e;-fx-border-width: 1px; -fx-padding: 1px;");
                break;
            default:
                questionTypeLabel.setStyle("-fx-text-fill: #f7ae4f; -fx-border-color: #f7ae4f;-fx-border-width: 1px; -fx-padding: 1px;");
                break;
        }

        //        题目内容区域（改）
        questionContentTextArea.prefWidthProperty().bind(paper.prefWidthProperty().multiply(0.8));
        VBox vBox8 = new VBox();
        ArrayList<String> QueContentPicUrlList = new ArrayList<>();     //题目内容里也可能出现图片，用这个来存图片url
        String queContent = questionAnswer.getText();
        if(queContent.contains("src=")) {
            String queContent_text = queContent.substring(3,queContent.indexOf("</p>"));        //先存下问题内容中的文字部分
            questionContentTextArea.setText(queContent_text);
            queContent = queContent.substring(queContent.indexOf("</p>")+4);
            while(queContent.contains("src=")) {                    //获取问题内容中的图片url
                int firstFlag = queContent.indexOf("src=")+5;
                int lastFlag = queContent.indexOf("/>")-1;
                String PicUrl = queContent.substring(firstFlag,lastFlag);          //截取
                QueContentPicUrlList.add(PicUrl);
                queContent = queContent.substring(queContent.indexOf("</p>")+4);
            }
            questionContentPicHbox.getChildren().clear();
            for (String value : QueContentPicUrlList) {                    //遍历设置图片样式
                ImageView imageView = new ImageView();
                HBox hBox5 = new HBox();
                hBox5.setStyle("-fx-pref-width: 5;");
                Image image = new Image(value);
                double w = image.getWidth();
                double h = image.getHeight();
                double max = Math.max(w, h);
                int width = (int) (500 * w / max);
                int height = (int) (500 * h / max);
                imageView.setFitHeight(height);
                imageView.setFitWidth(width);
                imageView.setImage(image);
                questionContentPicHbox.getChildren().addAll(imageView,hBox5);
            }
        }
        else {
            String text = questionAnswer.getText().substring(3, questionAnswer.getText().length() - 4);  //截取题目内容
            questionContentTextArea.setText(text);
        }
        questionContentTextArea.setStyle("-fx-border-width: 0;-fx-faint-focus-color: transparent;");
        questionContentTextArea.setWrapText(true);
        questionContentTextArea.setEditable(false);  //设置不能修改
        questionContentTextArea.setPrefHeight(100);
        if(questionType.equals("选择题")) {    //如果为选择题的话也要将选项放到盒子里
            optionVbox.getChildren().clear();
            for (int j = 0; j < questionAnswer.getOptions().size(); j++) {
                VBox vBox8_1 = new VBox();
                vBox8_1.setStyle("-fx-pref-height: 8");
                String optionContent = questionAnswer.getOptions().get(j).replace(".","、");
                Label label_options = new Label(optionContent);
                optionVbox.getChildren().addAll(vBox8_1,label_options);
            }
        }

//        题目分值区域
//        scoreHBox.prefWidthProperty().bind(paper.widthProperty());
        scoreLongHBox.prefWidthProperty().bind(paper.prefWidthProperty().multiply(0.89));
        scoreTextHBox.prefWidthProperty().bind(paper.prefWidthProperty().multiply(0.1));

        String score = "分值: "+questionAnswer.getScore()+"分";
        questionScoreLabel.setText(score);
        scoreTextHBox.setAlignment(Pos.CENTER);
//        scoreLongHBox.setStyle("-fx-background-color: pink;");
//        scoreTextHBox.setStyle("-fx-background-color: skyblue;");


//        学生答案区域


        if (questionType.equals("选择题")||questionType.equals("判断题")||questionType.equals("填空题")) {
            studentAnswerContentHBox.getChildren().clear();
            String stuAnswe = "";
            if (questionAnswer.getStuAnswer().get(0).equals("√")) {
                stuAnswe = "T";
            }
            else if(questionAnswer.getStuAnswer().get(0).equals("X")) {
                stuAnswe = "F";
            }
            else stuAnswe = questionAnswer.getStuAnswer().get(0);
            Label label2 = new Label(stuAnswe);
            studentAnswerContentHBox.getChildren().add(label2);
        }
        else {
            HBox hBox_stuAnswerPic = new HBox();
            for (int j = 0; j < questionAnswer.getStuAnswer().size(); j++) {
                ImageView imageView = new ImageView();
                HBox hBox5 = new HBox();
                hBox5.setStyle("-fx-pref-width: 5;");
                Image image = new Image(questionAnswer.getStuAnswer().get(j));
                double w = image.getWidth();
                double h = image.getHeight();
                double max = Math.max(w, h);
                int width = (int) (500 * w / max);
                int height = (int) (500 * h / max);
                imageView.setFitHeight(height);
                imageView.setFitWidth(width);
                imageView.setImage(image);
                hBox_stuAnswerPic.getChildren().addAll(hBox5,imageView);
            }
            studentAnswerContentHBox.getChildren().clear();
            studentAnswerContentHBox.getChildren().add(hBox_stuAnswerPic);
        }


//        正确答案区域

        if (questionType.equals("选择题")||questionType.equals("判断题")||questionType.equals("填空题")) {
            String RightAnswe = "";
            if (questionAnswer.getAnswer().get(0).equals("√")) {
                RightAnswe= "T";
            }
            else if(questionAnswer.getAnswer().get(0).equals("X")) {
                RightAnswe = "F";
            }
            else RightAnswe = questionAnswer.getAnswer().get(0);
            Label label3 = new Label(RightAnswe);
            label3.setStyle(" -fx-text-fill: #3498db;");
            RightAnswerContentHBox.getChildren().clear();
            RightAnswerContentHBox.getChildren().add(label3);
        }
        else {
            RightAnswerContentHBox.getChildren().clear();
            VBox vBox_text = new VBox();
            for (int j = 0; j < questionAnswer.getAnswer().size(); j++) {
                HBox hBox5 = new HBox();
                VBox vBox5 = new VBox();
                hBox5.setStyle("-fx-pref-width: 5;");
                vBox5.setStyle("-fx-pref-height: 5;");
                //正确答案是图片的情况
                if(questionAnswer.getAnswer().get(j).contains("src")) {
                    //对获取的图片url进行处理
                    int firstFlag  = questionAnswer.getAnswer().get(j).indexOf("src=")+5;
                    int lastFlag = questionAnswer.getAnswer().get(j).indexOf("/>")-1;
                    String RightAnswerPicUrl = questionAnswer.getAnswer().get(j).substring(firstFlag,lastFlag);
                    System.out.println("截取的url如下");
                    System.out.println(RightAnswerPicUrl);
                    //将获取的图片放到vbox里进行渲染
                    ImageView imageView = new ImageView();
                    imageView.setImage(new Image(RightAnswerPicUrl));
                    RightAnswerContentHBox.getChildren().addAll(imageView,hBox5);
                }
                //正确答案是文字的情况
                else {
                    Label label_RightAnswer = new Label(questionAnswer.getAnswer().get(j));
                    label_RightAnswer.setStyle("-fx-text-fill: #3498db;");
                    vBox_text.getChildren().addAll(label_RightAnswer,vBox5);
                    if ((j+1)==questionAnswer.getAnswer().size()) {
                        RightAnswerContentHBox.getChildren().add(vBox_text);
                    }
                }
            }
        }


//        解析区域

        analyze.setText(questionAnswer.getAnalysis());

        //      上一题、下一题区域
        jumpLongHBox.prefWidthProperty().bind( paper.prefWidthProperty().multiply(0.7));
        jumpButtonHBox.prefWidthProperty().bind( paper.prefWidthProperty().multiply(0.3));
        //设置按钮样式
        jumpButtonHBox.setAlignment(Pos.CENTER);
//        jumpLongHBox.setStyle("-fx-background-color: pink;");
//        jumpButtonHBox.setStyle("-fx-background-color: skyblue;");
    }
    //    渲染答题卡的方法
    public void  showQuestionCard() {
        mainCardBox.getChildren().clear();
        int queNum = 0;  //记录题数
        int queTypeNum = 1;//记录题型数目
        //有选择题时先渲染选择题的样式
        if(judgeAnswerPartDto.getSelectResultStatusList()!=null||judgeAnswerPartDto.getSelectResultStatusList().get(0)!=null) {
            VBox choiceVBox = new VBox();    //渲染选择题的大格子
            HBox hBox_fenshu = new HBox();
            HBox hBox20 = new HBox();        //用来隔开题型和该题型得分
            hBox20.setStyle("-fx-pref-width: 20");
            queTypeNum++;
            Label choiceLabel = new Label("一、选择题");
            choiceLabel.setStyle("-fx-font-size: 13px");

            String StuScore = String.valueOf(judgeAnswerPartDto.getQuestionScore().getSelectScore());       //获取学生该题型的得分和该题型的总分
            String totalScore = String.valueOf(paperAnswerPartDto.getQuestionScore().getSelectScore());
            Label choiceScoreLabel = new Label(StuScore+"分"+"/"+totalScore+"分");
            choiceScoreLabel.setStyle("-fx-font-size: 13px");
            hBox_fenshu.getChildren().addAll(choiceLabel,hBox20,choiceScoreLabel);
            VBox vBox1 = new VBox();                       //用来凑边距的
            vBox1.setStyle("-fx-pref-height: 5");
            choiceVBox.getChildren().addAll(hBox_fenshu,vBox1);
            List<HBox> ListBox10 = new ArrayList<>();        //存10个选择题一大行的那个大型hbox
            for (int j = 0; j < judgeAnswerPartDto.getSelectResultStatusList().size(); j++) {
                if(j%10==0) ListBox10.add(new HBox());
            }
            for (int i=0,j = 0; j < judgeAnswerPartDto.getSelectResultStatusList().size(); j++) {
                if(j%5==0) {
                    if(j%10==0&&j!=0) i++;
                    ListBox10.get(i).getChildren().add(new HBox());          //在存10个选择题一大行的那个大型hbox里每5个选择题放一个中型hbox
                }
            }
            for (int i = 0; i < judgeAnswerPartDto.getSelectResultStatusList().size(); i++) {
                HBox hBox15 = new HBox();
                hBox15.setStyle("-fx-pref-width: 15");
                //根据对错设置按钮样式
                Button button = new Button();
                button.setText(""+(i+1));
                if(judgeAnswerPartDto.getSelectResultStatusList().get(i).equals("true")) {
                    //注意这个setStyle要一次把所有属性都写进去，不能分开，否则第二个setStyle的属性会把第一个给覆盖，注意避坑
                    button.setStyle( "-fx-font-size: 13px;" +
                            " -fx-pref-width: 36px;" +
                            " -fx-pref-height: 36px;" +
                            " -fx-text-fill: white;" +
                            " -fx-background-color: #46ce87;" +
                            " -fx-background-radius: 35px;");
                } else {
                    button.setStyle(" -fx-font-size: 13px;" +
                            " -fx-pref-width:36px;" +
                            " -fx-pref-height: 36px;" +
                            " -fx-text-fill: white;" +
                            " -fx-background-color: #f04844;" +
                            " -fx-background-radius: 35px;");
                }
                int finalI = i+1;
                button.setOnMouseClicked(new EventHandler<MouseEvent>() {
                    @Override
                    public void handle(MouseEvent event) {
                        nowQuestionId = paperAnswerPartDto.getQuestionIdLists().getSelectIdList().get(finalI-1);
                        nowQuetionNum = finalI;
                        ObjToSub(paperAnswerPartDto.getQuestionIdLists().getSelectIdList().get(finalI-1),"选择题",finalI+"");
                    }
                });
                if(i%5==0) {
                    HBox hBox50 = new HBox();
                    hBox50.setStyle("-fx-pref-width: 50");
                    //由于ListBox10.get((i/10)).getChildren()中的hbox已经变为Node类，无法再用getChildren().add()方法再往里填元素了
                    //所以下面是根据index先将对应的hbox去除掉，再将已经填好元素的hbox再放到ListBox10.get((i/10)).getChildren()原来的位置上
                    ListBox10.get((i/10)).getChildren().remove((i%10)/5);
                    HBox hBox = new HBox();
                    hBox.getChildren().addAll(hBox50,hBox15,button);
                    ListBox10.get((i/10)).getChildren().add((i%10)/5,hBox);
                }else {
                    HBox hBox = (HBox) ListBox10.get((i/10)).getChildren().get((i%10)/5);
                    hBox.getChildren().addAll(hBox15,button);
                    ListBox10.get((i/10)).getChildren().remove((i%10)/5);
                    ListBox10.get((i/10)).getChildren().add((i%10)/5,hBox);
                }
            }
            for (HBox hBox : ListBox10) {
                VBox vBox = new VBox();
                vBox.setStyle("-fx-pref-height: 10");
                choiceVBox.getChildren().addAll(hBox,vBox);
            }
            mainCardBox.getChildren().add(choiceVBox);
            queNum = queNum+judgeAnswerPartDto.getSelectResultStatusList().size();
        }


        //有判断题时第二个渲染判断题的样式
        if(judgeAnswerPartDto.getJudgeResultStatusList()!=null||judgeAnswerPartDto.getJudgeResultStatusList().get(0)!=null) {
            VBox JudgeVBox = new VBox();    //渲染判断题的大格子
            HBox hBox_fenshu = new HBox();
            HBox hBox20 = new HBox();        //用来隔开题型和该题型得分
            hBox20.setStyle("-fx-pref-width: 20");
            String queType = "";
            if (queTypeNum==1)  queType = "一、判断题";
            else if (queTypeNum==2)  queType = "二、判断题";
            else if(queTypeNum==3) queType = "三、判断题";
            queTypeNum++;
            Label judgeLabel = new Label(queType);
            judgeLabel.setStyle("-fx-font-size: 13px");
            String StuScore = String.valueOf(judgeAnswerPartDto.getQuestionScore().getJudgeScore());       //获取学生该题型的得分和该题型的总分
            String totalScore = String.valueOf(paperAnswerPartDto.getQuestionScore().getJudgeScore());
            Label judgeScoreLabel = new Label(StuScore+"分"+"/"+totalScore+"分");
            judgeScoreLabel.setStyle("-fx-font-size: 13px");
            hBox_fenshu.getChildren().addAll(judgeLabel,hBox20,judgeScoreLabel);
            VBox vBox1 = new VBox();                       //用来凑边距的
            vBox1.setStyle("-fx-pref-height: 5");
            JudgeVBox.getChildren().addAll(hBox_fenshu,vBox1);
            List<HBox> ListBox10 = new ArrayList<>();        //存10个判断题一大行的那个大型hbox
            for (int j = 0; j < judgeAnswerPartDto.getJudgeResultStatusList().size(); j++) {
                if(j%10==0) ListBox10.add(new HBox());
            }
            for (int i=0,j = 0; j < judgeAnswerPartDto.getJudgeResultStatusList().size(); j++) {
                if(j%5==0) {
                    if(j%10==0&&j!=0) i++;
                    ListBox10.get(i).getChildren().add(new HBox());          //在存10个选择题一大行的那个大型hbox里每5个选择题放一个中型hbox
                }
            }
            for (int i = 0; i < judgeAnswerPartDto.getJudgeResultStatusList().size(); i++) {
                HBox hBox15 = new HBox();
                hBox15.setStyle("-fx-pref-width: 15");
                //根据对错设置按钮样式
                Button button = new Button();
                button.setText(""+(queNum+1+i));
                int finalI = i;
                int finalQueNum = queNum+i+1;
                button.setOnMouseClicked(new EventHandler<MouseEvent>() {
                    @Override
                    public void handle(MouseEvent event) {
                        nowQuestionId = paperAnswerPartDto.getQuestionIdLists().getJudgeIdList().get(finalI);
                        nowQuetionNum = finalQueNum;
                        ObjToSub(paperAnswerPartDto.getQuestionIdLists().getJudgeIdList().get(finalI),"判断题", finalQueNum+"");
                    }
                });
                if(judgeAnswerPartDto.getJudgeResultStatusList().get(i).equals("true")) {
                    //注意这个setStyle要一次把所有属性都写进去，不能分开，否则第二个setStyle的属性会把第一个给覆盖，注意避坑
                    button.setStyle( "-fx-font-size: 13px;" +
                            " -fx-pref-width: 36px;" +
                            " -fx-pref-height: 36px;" +
                            " -fx-text-fill: white;" +
                            " -fx-background-color: #46ce87;" +
                            " -fx-background-radius: 35px;");
                } else {
                    button.setStyle(" -fx-font-size: 13px;" +
                            " -fx-pref-width:36px;" +
                            " -fx-pref-height: 36px;" +
                            " -fx-text-fill: white;" +
                            " -fx-background-color: #f04844;" +
                            " -fx-background-radius: 35px;");
                }
                if(i%5==0) {
                    HBox hBox50 = new HBox();
                    hBox50.setStyle("-fx-pref-width: 50");
                    //由于ListBox10.get((i/10)).getChildren()中的hbox已经变为Node类，无法再用getChildren().add()方法再往里填元素了
                    //所以下面是根据index先将对应的hbox去除掉，再将已经填好元素的hbox再放到ListBox10.get((i/10)).getChildren()原来的位置上
                    ListBox10.get((i/10)).getChildren().remove((i%10)/5);
                    HBox hBox = new HBox();
                    hBox.getChildren().addAll(hBox50,hBox15,button);
                    ListBox10.get((i/10)).getChildren().add((i%10)/5,hBox);
                }else {
                    HBox hBox = (HBox) ListBox10.get((i/10)).getChildren().get((i%10)/5);
                    hBox.getChildren().addAll(hBox15,button);
                    ListBox10.get((i/10)).getChildren().remove((i%10)/5);
                    ListBox10.get((i/10)).getChildren().add((i%10)/5,hBox);
                }
            }
            for (HBox hBox : ListBox10) {
                VBox vBox = new VBox();
                vBox.setStyle("-fx-pref-height: 10");
                JudgeVBox.getChildren().addAll(hBox,vBox);
            }
            mainCardBox.getChildren().add(JudgeVBox);
            queNum = queNum+judgeAnswerPartDto.getJudgeResultStatusList().size();
        }

        //有填空题时第三个渲染填空题的样式
        if(judgeAnswerPartDto.getFillResultStatusList()!=null||judgeAnswerPartDto.getFillResultStatusList().get(0)!=null) {
            VBox fillVBox = new VBox();    //渲染填空题的大格子
            HBox hBox_fenshu = new HBox();
            HBox hBox20 = new HBox();        //用来隔开题型和该题型得分
            hBox20.setStyle("-fx-pref-width: 20");
            String queType = "";
            if (queTypeNum==1)  queType = "一、填空题";
            else if (queTypeNum==2)  queType = "二、填空题";
            else if(queTypeNum==3) queType = "三、填空题";
            queTypeNum++;
            Label fillLabel = new Label(queType);
            fillLabel.setStyle("-fx-font-size: 13px");
            String StuScore = String.valueOf(judgeAnswerPartDto.getQuestionScore().getFillScore());       //获取学生该题型的得分和该题型的总分
            String totalScore = String.valueOf(paperAnswerPartDto.getQuestionScore().getFillScore());
            Label  fillScoreLabel = new Label(StuScore+"分"+"/"+totalScore+"分");
            fillScoreLabel.setStyle("-fx-font-size: 13px");
            hBox_fenshu.getChildren().addAll(fillLabel,hBox20,fillScoreLabel);
            VBox vBox1 = new VBox();                       //用来凑边距的
            vBox1.setStyle("-fx-pref-height: 5");
            fillVBox.getChildren().addAll(hBox_fenshu,vBox1);
            List<HBox> ListBox10 = new ArrayList<>();        //存10个判断题一大行的那个大型hbox
            for (int j = 0; j < judgeAnswerPartDto.getFillResultStatusList().size(); j++) {
                if(j%10==0) ListBox10.add(new HBox());
            }
            for (int i=0,j = 0; j < judgeAnswerPartDto.getFillResultStatusList().size(); j++) {
                if(j%5==0) {
                    if(j%10==0&&j!=0) i++;
                    ListBox10.get(i).getChildren().add(new HBox());          //在存10个选择题一大行的那个大型hbox里每5个选择题放一个中型hbox
                }
            }
            for (int i = 0; i < judgeAnswerPartDto.getFillResultStatusList().size(); i++) {
                int flag = 0;   //作为判断填空题是否有填错的空，1表示有，0表示无
                HBox hBox15 = new HBox();
                hBox15.setStyle("-fx-pref-width: 15");
                //根据对错设置按钮样式
                Button button = new Button();
                button.setText("" + (queNum + 1 + i));
                int finalI = i;
                int finalQueNum = queNum + 1 + i;
                button.setOnMouseClicked(new EventHandler<MouseEvent>() {
                    @Override
                    public void handle(MouseEvent event) {
                        nowQuestionId = paperAnswerPartDto.getQuestionIdLists().getFillIdList().get(finalI);
                        nowQuetionNum = finalQueNum;
                        ObjToSub(paperAnswerPartDto.getQuestionIdLists().getFillIdList().get(finalI),"填空题", finalQueNum+"");
                    }
                });
                for (int j = 0; j < judgeAnswerPartDto.getFillResultStatusList().get(i).size(); j++) {
                    if (judgeAnswerPartDto.getFillResultStatusList().get(i).get(j).equals("false")) {
                        button.setStyle(" -fx-font-size: 13px;" +
                                " -fx-pref-width:36px;" +
                                " -fx-pref-height: 36px;" +
                                " -fx-text-fill: white;" +
                                " -fx-background-color: #f04844;" +
                                " -fx-background-radius: 35px;");
                        flag = 1;
                        break;
                    }
                }
                if(flag==0) {
                    button.setStyle( "-fx-font-size: 13px;" +
                            " -fx-pref-width: 36px;" +
                            " -fx-pref-height: 36px;" +
                            " -fx-text-fill: white;" +
                            " -fx-background-color: #46ce87;" +
                            " -fx-background-radius: 35px;");
                }
                if(i%5==0) {
                    HBox hBox50 = new HBox();
                    hBox50.setStyle("-fx-pref-width: 50");
                    //由于ListBox10.get((i/10)).getChildren()中的hbox已经变为Node类，无法再用getChildren().add()方法再往里填元素了
                    //所以下面是根据index先将对应的hbox去除掉，再将已经填好元素的hbox再放到ListBox10.get((i/10)).getChildren()原来的位置上
                    ListBox10.get((i/10)).getChildren().remove((i%10)/5);
                    HBox hBox = new HBox();
                    hBox.getChildren().addAll(hBox50,hBox15,button);
                    ListBox10.get((i/10)).getChildren().add((i%10)/5,hBox);
                }else {
                    HBox hBox = (HBox) ListBox10.get((i/10)).getChildren().get((i%10)/5);
                    hBox.getChildren().addAll(hBox15,button);
                    ListBox10.get((i/10)).getChildren().remove((i%10)/5);
                    ListBox10.get((i/10)).getChildren().add((i%10)/5,hBox);
                }
            }
            for (HBox hBox : ListBox10) {
                VBox vBox = new VBox();
                vBox.setStyle("-fx-pref-height: 10");
                fillVBox.getChildren().addAll(hBox,vBox);
            }
            mainCardBox.getChildren().add(fillVBox);
            queNum = queNum+judgeAnswerPartDto.getFillResultStatusList().size();
        }


        //有简答题第四个渲染简答题样式
        if(paperAnswerPartDto.getQuestionSize().getWriteSize()!=0) {
            VBox shortVBox = new VBox();    //渲染简答题的大格子
            HBox hBox_fenshu = new HBox();
            HBox hBox20 = new HBox();        //用来隔开题型和该题型得分
            hBox20.setStyle("-fx-pref-width: 20");
            String queType = "";
            if (queTypeNum==1)  queType = "一、简答题";
            else if (queTypeNum==2)  queType = "二、简答题";
            else if(queTypeNum==3) queType = "三、简答题";
            else if(queTypeNum==4) queType = "四、简答题";
            queTypeNum++;
            Label shortLabel = new Label(queType);
            shortLabel.setStyle("-fx-font-size: 13px");


            String StuScore = String.valueOf(judgeAnswerPartDto.getQuestionScore().getWriteScore());       //获取学生该题型的得分和该题型的总分
            String totalScore = String.valueOf(paperAnswerPartDto.getQuestionScore().getWriteScore());
            Label   shortScoreLabel = new Label(StuScore+"分"+"/"+totalScore+"分");
            shortScoreLabel.setStyle("-fx-font-size: 13px");
            hBox_fenshu.getChildren().addAll(shortLabel,hBox20,shortScoreLabel);
            VBox vBox1 = new VBox();                       //用来凑边距的
            vBox1.setStyle("-fx-pref-height: 5");
            shortVBox.getChildren().addAll(hBox_fenshu,vBox1);
            List<HBox> ListBox10 = new ArrayList<>();        //存10个简答题一大行的那个大型hbox
            for (int j = 0; j < paperAnswerPartDto.getQuestionSize().getWriteSize(); j++) {
                if(j%10==0) ListBox10.add(new HBox());
            }
            for (int i=0,j = 0; j < paperAnswerPartDto.getQuestionSize().getWriteSize(); j++) {
                if(j%5==0) {
                    if(j%10==0&&j!=0) i++;
                    ListBox10.get(i).getChildren().add(new HBox());          //在存10个选择题一大行的那个大型hbox里每5个选择题放一个中型hbox
                }
            }
            for (int i = 0; i < paperAnswerPartDto.getQuestionSize().getWriteSize(); i++) {
                HBox hBox15 = new HBox();
                hBox15.setStyle("-fx-pref-width: 15");
                //根据对错设置按钮样式
                Button button = new Button();
                button.setText("" + (queNum + 1 + i));
                int finalQueNum = queNum + 1 + i;
                int finalI = i;
                button.setOnMouseClicked(new EventHandler<MouseEvent>() {
                    @Override
                    public void handle(MouseEvent event) {
                        nowQuestionId = paperAnswerPartDto.getQuestionIdLists().getWriteIdList().get(finalI);
                        nowQuetionNum = finalQueNum;
                        ObjToSub(paperAnswerPartDto.getQuestionIdLists().getWriteIdList().get(finalI), "简答题", finalQueNum+"");
                    }
                });
                button.setStyle(" -fx-font-size: 13px;" +
                        " -fx-pref-width: 36px;" +
                        " -fx-pref-height: 36px;" +
                        " -fx-text-fill: #54a8e0;" +
                        " -fx-background-color: white;" +
                        " -fx-background-radius: 35px;" +
                        " -fx-border-color: #54a8e0;" +
                        " -fx-border-radius: 35px;");
                if(i%5==0) {
                    HBox hBox50 = new HBox();
                    hBox50.setStyle("-fx-pref-width: 50");
                    //由于ListBox10.get((i/10)).getChildren()中的hbox已经变为Node类，无法再用getChildren().add()方法再往里填元素了
                    //所以下面是根据index先将对应的hbox去除掉，再将已经填好元素的hbox再放到ListBox10.get((i/10)).getChildren()原来的位置上
                    ListBox10.get((i/10)).getChildren().remove((i%10)/5);
                    HBox hBox = new HBox();
                    hBox.getChildren().addAll(hBox50,hBox15,button);
                    ListBox10.get((i/10)).getChildren().add((i%10)/5,hBox);
                }else {
                    HBox hBox = (HBox) ListBox10.get((i/10)).getChildren().get((i%10)/5);
                    hBox.getChildren().addAll(hBox15,button);
                    ListBox10.get((i/10)).getChildren().remove((i%10)/5);
                    ListBox10.get((i/10)).getChildren().add((i%10)/5,hBox);
                }
            }
            for (HBox hBox : ListBox10) {
                VBox vBox = new VBox();
                vBox.setStyle("-fx-pref-height: 10");
                shortVBox.getChildren().addAll(hBox,vBox);
            }
            mainCardBox.getChildren().add(shortVBox);
            queNum = queNum+paperAnswerPartDto.getQuestionSize().getWriteSize();
        }

    }
    //          获取当前学生的客观题信息并渲染答题情况界面
    public void  GetObjectiveQuestion(String testid,String paperid,String studentid,int nowStuNums) {
//        初始化客观题信息界面
        if(flag==0) flag = 1;
        else SubjToOb();
        //调用接口获取所有信息保存在公共变量中
        paperAnswerPartDto  = getStuObjectiveQueMsgServices.getPaperAnswerPartDto(paperId).getData();
        System.out.println("这是从后端获取的数据1");
        System.out.println("这是学生id"+nowStuId);
        System.out.println(paperAnswerPartDto);
        studentAnswerPartDto = getStuObjectiveQueMsgServices.getStudentAnswerPartDto(testId, paperId, nowStuId).getData();
        System.out.println("这是从后端获取的数据2");
        System.out.println(studentAnswerPartDto);
        judgeAnswerPartDto = getStuObjectiveQueMsgServices.getJudgeAnswerPartDto(testId, paperId, nowStuId).getData();
        System.out.println("这是从后端获取的数据3");
        System.out.println(judgeAnswerPartDto);
//        //获取相应学生考试的所有信息
//        paperAnswerPartDto  = getStuObjectiveQueMsgServices.getPaperAnswerPartDto(paperid).getData();
//        studentAnswerPartDto = getStuObjectiveQueMsgServices.getStudentAnswerPartDto(testid, paperid,studentid).getData();
//        judgeAnswerPartDto = getStuObjectiveQueMsgServices.getJudgeAnswerPartDto(testid,  paperid, studentid).getData();
        nowStuNum = nowStuNums;
        System.out.println("现在的学生序号--"+nowStuNum);
        nowStuId = studentid;
        ObjectiveQuetions.getChildren().clear();
        System.out.println("到这里了");
        int queNum = 0;  //记录题数
        int queTypeNum = 1; //记录题目类型数目
        //有选择题时先渲染选择题的样式
        if (judgeAnswerPartDto.getSelectResultStatusList()!=null||judgeAnswerPartDto.getSelectResultStatusList().get(0) != null) {
            VBox choiceVBox = new VBox();    //渲染选择题的大格子
            Label choiceLabel = new Label("一、选择题");
            queTypeNum++;
            choiceLabel.setStyle("-fx-font-size: 13px");
            VBox vBox1 = new VBox();                       //用来凑边距的
            vBox1.setStyle("-fx-pref-height: 5");
            choiceVBox.getChildren().addAll(choiceLabel, vBox1);
            List<HBox> ListBox10 = new ArrayList<>();        //存10个选择题一大行的那个大型hbox
            for (int j = 0; j < judgeAnswerPartDto.getSelectResultStatusList().size(); j++) {
                if (j % 10 == 0) ListBox10.add(new HBox());
            }
            for (int i = 0, j = 0; j < judgeAnswerPartDto.getSelectResultStatusList().size(); j++) {
                if (j % 5 == 0) {
                    if (j % 10 == 0 && j != 0) i++;
                    ListBox10.get(i).getChildren().add(new HBox());          //在存10个选择题一大行的那个大型hbox里每5个选择题放一个中型hbox
                }
            }
            for (int i = 0; i < judgeAnswerPartDto.getSelectResultStatusList().size(); i++) {
                HBox hBox15 = new HBox();
                hBox15.setStyle("-fx-pref-width: 15");
                //根据对错设置按钮样式
                Button button = new Button();
                button.setText(studentAnswerPartDto.getSelectResultList().get(i));
                if (judgeAnswerPartDto.getSelectResultStatusList().get(i).equals("true")) {
                    //注意这个setStyle要一次把所有属性都写进去，不能分开，否则第二个setStyle的属性会把第一个给覆盖，注意避坑
                    button.setStyle("-fx-font-size: 13px;" +
                            " -fx-pref-width: 36px;" +
                            " -fx-pref-height: 36px;" +
                            " -fx-text-fill: white;" +
                            " -fx-background-color: #46ce87;" +
                            " -fx-background-radius: 35px;");
                } else {
                    button.setStyle(" -fx-font-size: 13px;" +
                            " -fx-pref-width:36px;" +
                            " -fx-pref-height: 36px;" +
                            " -fx-text-fill: white;" +
                            " -fx-background-color: #f04844;" +
                            " -fx-background-radius: 35px;");
                }
                if (i % 5 == 0) {
                    HBox hBox50 = new HBox();
                    hBox50.setStyle("-fx-pref-width: 50");
                    String text = "";   //存储1-5、6-10这样的字符串
                    //第一个if处理题目数量为6、11、16、21这样题目数量刚好是5的倍数多1的情况
                    if (i == judgeAnswerPartDto.getSelectResultStatusList().size() - 1)
                        text = judgeAnswerPartDto.getSelectResultStatusList().size() + ":";
                        //处理总的题目数量不是5的倍数的情况
                    else if (i + 5 >= judgeAnswerPartDto.getSelectResultStatusList().size())
                        text = i + 1 + "-" +judgeAnswerPartDto.getSelectResultStatusList().size() + ":";
                    else
                        text = i + 1 + "-" + (i + 5) + ":";
                    Label label = new Label(text);
                    label.setStyle("-fx-pref-width: 50;-fx-pref-height: 36px;");
                    label.setAlignment(Pos.CENTER);
                    //由于ListBox10.get((i/10)).getChildren()中的hbox已经变为Node类，无法再用getChildren().add()方法再往里填元素了
                    //所以下面是根据index先将对应的hbox去除掉，再将已经填好元素的hbox再放到ListBox10.get((i/10)).getChildren()原来的位置上
                    ListBox10.get((i / 10)).getChildren().remove((i % 10) / 5);
                    HBox hBox = new HBox();
                    hBox.getChildren().addAll(hBox50, label, hBox15, button);
                    ListBox10.get((i / 10)).getChildren().add((i % 10) / 5, hBox);
                } else {
                    HBox hBox = (HBox) ListBox10.get((i / 10)).getChildren().get((i % 10) / 5);
                    hBox.getChildren().addAll(hBox15, button);
                    ListBox10.get((i / 10)).getChildren().remove((i % 10) / 5);
                    ListBox10.get((i / 10)).getChildren().add((i % 10) / 5, hBox);
                }
            }
            for (HBox hBox : ListBox10) {
                VBox vBox = new VBox();
                vBox.setStyle("-fx-pref-height: 10");
                choiceVBox.getChildren().addAll(hBox, vBox);
            }
            ObjectiveQuetions.getChildren().add(choiceVBox);
        }

        //有判断题时第二个渲染判断题的样式
        if (judgeAnswerPartDto.getJudgeResultStatusList()!=null||judgeAnswerPartDto.getJudgeResultStatusList().get(0) != null) {
            VBox judgeVBox = new VBox();    //渲染判断题的大格子
            String queType = "";
            if (queTypeNum == 1) queType = "一、判断题";
            else if (queTypeNum == 2) queType = "二、判断题";
            else if (queTypeNum == 3) queType = "三、判断题";
            Label judgeLabel = new Label(queType);
            queTypeNum++;
            judgeLabel.setStyle("-fx-font-size: 13px");
            VBox vBox1 = new VBox();                       //用来凑边距的
            vBox1.setStyle("-fx-pref-height: 5");
            judgeVBox.getChildren().addAll(judgeLabel, vBox1);
            List<HBox> ListBox10 = new ArrayList<>();        //存10个判断题一大行的那个大型hbox
            for (int j = 0; j < judgeAnswerPartDto.getJudgeResultStatusList().size(); j++) {
                if (j % 10 == 0) ListBox10.add(new HBox());
            }

            for (int i = 0, j = 0; j < judgeAnswerPartDto.getJudgeResultStatusList().size(); j++) {
                if (j % 5 == 0) {
                    if (j % 10 == 0 && j != 0) i++;
                    ListBox10.get(i).getChildren().add(new HBox());          //在存10个选择题一大行的那个大型hbox里每5个选择题放一个中型hbox
                }
            }
            for (int i = 0; i < judgeAnswerPartDto.getJudgeResultStatusList().size(); i++) {
                HBox hBox15 = new HBox();
                hBox15.setStyle("-fx-pref-width: 15");
                //根据对错设置按钮样式
                Button button = new Button();
                if(studentAnswerPartDto.getJudgeResultList().get(i).equals("√")||studentAnswerPartDto.getJudgeResultList().get(i).equals("T"))
                    button.setText("T");
                else if (studentAnswerPartDto.getJudgeResultList().get(i).equals("X")||studentAnswerPartDto.getJudgeResultList().get(i).equals("F"))
                    button.setText("F");
                else
                    button.setText(studentAnswerPartDto.getJudgeResultList().get(i));

                if (judgeAnswerPartDto.getJudgeResultStatusList().get(i).equals("true")) {
                    //注意这个setStyle要一次把所有属性都写进去，不能分开，否则第二个setStyle的属性会把第一个给覆盖，注意避坑
                    button.setStyle("-fx-font-size: 13px;" +
                            " -fx-pref-width: 36px;" +
                            " -fx-pref-height: 36px;" +
                            " -fx-text-fill: white;" +
                            " -fx-background-color: #46ce87;" +
                            " -fx-background-radius: 35px;");
                } else {
                    button.setStyle(" -fx-font-size: 13px;" +
                            " -fx-pref-width:36px;" +
                            " -fx-pref-height: 36px;" +
                            " -fx-text-fill: white;" +
                            " -fx-background-color: #f04844;" +
                            " -fx-background-radius: 35px;");
                }
                if (i % 5 == 0) {
                    HBox hBox50 = new HBox();
                    hBox50.setStyle("-fx-pref-width: 50");
                    String text = "";   //存储1-5、6-10这样的字符串
                    //第一个if处理题目数量为6、11、16、21这样题目数量刚好是5的倍数多1的情况
                    if (i == judgeAnswerPartDto.getJudgeResultStatusList().size() - 1)
                        text = judgeAnswerPartDto.getJudgeResultStatusList().size() + ":";
                        //处理总的题目数量不是5的倍数的情况
                    else if (i + 5 >= judgeAnswerPartDto.getJudgeResultStatusList().size())
                        text = i + 1 + "-" + judgeAnswerPartDto.getJudgeResultStatusList().size() + ":";
                    else
                        text = i + 1 + "-" + (i + 5) + ":";
                    Label label = new Label(text);
                    label.setStyle("-fx-pref-width: 50;-fx-pref-height: 36px;");
                    label.setAlignment(Pos.CENTER);
                    //由于ListBox10.get((i/10)).getChildren()中的hbox已经变为Node类，无法再用getChildren().add()方法再往里填元素了
                    //所以下面是根据index先将对应的hbox去除掉，再将已经填好元素的hbox再放到ListBox10.get((i/10)).getChildren()原来的位置上
                    ListBox10.get((i / 10)).getChildren().remove((i % 10) / 5);
                    HBox hBox = new HBox();
                    hBox.getChildren().addAll(hBox50, label, hBox15, button);
                    ListBox10.get((i / 10)).getChildren().add((i % 10) / 5, hBox);
                } else {
                    HBox hBox = (HBox) ListBox10.get((i / 10)).getChildren().get((i % 10) / 5);
                    hBox.getChildren().addAll(hBox15, button);
                    ListBox10.get((i / 10)).getChildren().remove((i % 10) / 5);
                    ListBox10.get((i / 10)).getChildren().add((i % 10) / 5, hBox);
                }
            }
            for (HBox hBox : ListBox10) {
                VBox vBox = new VBox();
                vBox.setStyle("-fx-pref-height: 10");
                judgeVBox.getChildren().addAll(hBox, vBox);
            }
            ObjectiveQuetions.getChildren().add(judgeVBox);
        }
        // 有填空题时第三个渲染填空题的样式
        if (judgeAnswerPartDto.getFillResultStatusList()!=null||judgeAnswerPartDto.getFillResultStatusList().get(0).get(0) != null) {
            VBox fillVBox = new VBox();    //渲染填空题的大格子
            String queType = "";
            if (queTypeNum == 1) queType = "一、填空题";
            else if (queTypeNum == 2) queType = "二、填空题";
            else if (queTypeNum == 3) queType = "三、填空题";
            Label fillLabel = new Label(queType);
            queTypeNum++;
            fillLabel.setStyle("-fx-font-size: 13px");
            fillVBox.getChildren().add(fillLabel);
            for (int j = 0; j < judgeAnswerPartDto.getFillResultStatusList().size(); j++) {
                VBox vBox8 = new VBox();
                vBox8.setStyle("-fx-pref-height: 8");
                fillVBox.getChildren().add(vBox8);

                HBox hBox_fillQuestionMsg = new HBox();   //一道填空题最外面的大盒子
//                hBox_fillQuestionMsg.setStyle(" -fx-pref-width: ;");
                HBox fillMsg_Left = new HBox();
                fillMsg_Left.setStyle("-fx-pref-width: 1300;");           //一行填空题的左边一大块
//                fillMsg_Left.prefWidthProperty().bind(paper.prefWidthProperty().multiply(0.9));
                HBox hBox50 = new HBox();
                hBox50.setStyle("-fx-pref-width: 50");
                fillMsg_Left.getChildren().add(hBox50);
                //填空题题号区域
                String text = "" + (j + 1) + "、";
                Label label1 = new Label(text);
                label1.setStyle("-fx-pref-width: 50;-fx-pref-height: 36px;");
                label1.setAlignment(Pos.CENTER);
                HBox hBox10_1 = new HBox();
                hBox10_1.setStyle("-fx-pref-width: 10");
                fillMsg_Left.getChildren().addAll(label1, hBox10_1);

                //填空题学生答案区域
                for (int k = 0; k < studentAnswerPartDto.getFillResultList().get(j).size(); k++) {
                    Label label = new Label(studentAnswerPartDto.getFillResultList().get(j).get(k));
                    if(judgeAnswerPartDto.getFillResultStatusList().get(j).get(k).equals("true")){
                        label.setStyle(" -fx-border-radius: 5px;" +
                                "-fx-padding: 5;"+
                                " -fx-border-color: #3498db;" +
                                " -fx-border-width: 1px;");
                    } else {
                        label.setStyle(" -fx-border-radius: 5px;" +
                                "-fx-padding: 5;"+
                                " -fx-border-color: rgb(245,138,136);" +
                                " -fx-text-fill: rgb(245,138,136);" +
                                " -fx-border-width: 1px;");
                    }
                    label.setAlignment(Pos.CENTER);
                    HBox hBox10 = new HBox();
                    hBox10.setStyle("-fx-pref-width: 10");
                    fillMsg_Left.getChildren().addAll(label, hBox10);
                }

                Label label = new Label("正确答案: ");
                label.setStyle("-fx-text-fill:#3498db;-fx-padding: 5;");
                fillMsg_Left.getChildren().add(label);


                //填空题正确答案区域
                for (int k = 0; k < paperAnswerPartDto.getFillResultList().get(j).size(); k++) {
                    Label label_rightAnswer = new Label(paperAnswerPartDto.getFillResultList().get(j).get(k));
                    label_rightAnswer.setStyle("-fx-text-fill:#3498db;-fx-padding: 5;");
                    label_rightAnswer.setAlignment(Pos.CENTER);
                    HBox hBox10 = new HBox();
                    hBox10.setStyle("-fx-pref-width: 10");
                    fillMsg_Left.getChildren().addAll(label_rightAnswer, hBox10);
                }

                hBox_fillQuestionMsg.getChildren().add(fillMsg_Left);

//                得分区域
                String score = judgeAnswerPartDto.getQuestionScore().getFillScoreList().get(j)+"";
                Label label_score = new Label("得分: "+score+"分");
                label_score.setStyle(" -fx-background-color: #e9e9e9; -fx-text-fill: #65605c;-fx-padding: 5;");
                label_score.setAlignment(Pos.CENTER);
                HBox fillMsg_Right = new HBox();
                HBox hBox50_1 = new HBox();
                hBox50_1.setStyle("-fx-pref-width: 50");
//                fillMsg_Right.setStyle("-fx-pref-width: 80");
//                fillMsg_Right.prefWidthProperty().bind(paper.prefWidthProperty().multiply(0.1));
                fillMsg_Right.getChildren().add(label_score);
                fillMsg_Right.setAlignment(Pos.BASELINE_RIGHT);
                hBox_fillQuestionMsg.getChildren().addAll(hBox50_1,fillMsg_Right);
                fillVBox.getChildren().add(hBox_fillQuestionMsg);
            }
            ObjectiveQuetions.getChildren().add(fillVBox);
        }
        //渲染答题卡区域
        showQuestionCard();
    }
}
